/*
 *  $Id: Connect.cs 1239 2011-03-23 12:51:24Z thenn.erannor $
 *  This file is a part of Ragima CCG.
 *  (C) 2008-2010 Ragima development group.
 *
 *  Licensed under the terms of the GNU GPL License version 2.
 *
 */

using System.Net;
using Nereal.Serialization;

namespace Ragima.Events {
    public class Connect : DirectConnectEvent {
        private bool _success;
        private EndPoint _point;

        public Connect(bool success, EndPoint point) {
            _success = success;
            _point = point;
        }

        protected override void ExecuteInner(DirectConnectScene scene) {
            if (_success) {
                if (scene.Mode.Master)
                    scene.Log.Add(Resources.DirectConnect.ConnectFrom, _point);
                else
                    scene.Log.Add(Resources.DirectConnect.ConnectComplete);
                scene.Mode.SendEvent(new CheckVersion());
            } else {
                scene.EnableConnectButtons(true);
                scene.Log.Add(Resources.DirectConnect.ConnectError);
            }
        }
    }
}
